home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Image Compression Mgr / Inside Mac ICM Code / icm3.c < prev    next >
Encoding:
Text File  |  1994-12-04  |  2.1 KB  |  92 lines  |  [TEXT/MPS ]

  1. /*
  2.   File:            icm4.h
  3.   Contains:        Resource Functions
  4.   Written by:    DTS and QT Engineering
  5.   Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  6.   Change History (most recent first):
  7.   <1>         12/4/94    khs        changed the format of the file to the new look and feel
  8.   To Do:
  9. */
  10.  
  11.  
  12. // INCLUDE FILES
  13. #include "icm.h"
  14.  
  15.  
  16. // FUNCTIONS
  17. void MakeMyResource(StandardFileReply fileReply,
  18.                     ImageDescriptionHandle description)
  19. {
  20.     OSErr error;
  21.     short rfRef;
  22.     Handle sequResource;
  23.  
  24.     FSpCreateResFile(&fileReply.sfFile, 'SEQM', 'SEQU', fileReply.sfScript);
  25.  
  26.     error = ResError();
  27.     if (error != dupFNErr)
  28.         CheckError(error, "\pFSpCreateResFile");
  29.  
  30.     rfRef = FSpOpenResFile(&fileReply.sfFile, fsRdWrPerm);
  31.     CheckError(ResError(), "\pFSpOpenResFile");
  32.  
  33.     SetResLoad(false);
  34.     sequResource = Get1Resource('SEQU', 128);
  35.     if (sequResource != nil)
  36.     {
  37.         RemoveResource(sequResource);
  38.     }
  39.     SetResLoad(true);
  40.     sequResource = (Handle)description;
  41.     error = HandToHand(&sequResource);
  42.     CheckError(error, "\pHandToHand");
  43.  
  44.     AddResource(sequResource, 'SEQU', 128, "\p");
  45.     CheckError(ResError(), "\pAddResource");
  46.     UpdateResFile(rfRef);
  47.     CheckError(ResError(), "\pUpdateResFile");
  48.  
  49.     CloseResFile(rfRef);
  50. }
  51.  
  52.  
  53. void SequenceSave(void)
  54. {
  55.     long filePos;
  56.     StandardFileReply fileReply;
  57.     short dfRef = 0;
  58.     OSErr error;
  59.     ImageDescriptionHandle description = nil;
  60.  
  61.     StandardPutFile("\p", "\pSequence File", &fileReply);
  62.     if (fileReply.sfGood)
  63.     {
  64.         if (!(fileReply.sfReplacing))
  65.         {
  66.             error = FSpCreate(&fileReply.sfFile, 'SEQM', 'SEQU', fileReply.sfScript);
  67.             CheckError(error, "\pFSpCreate");
  68.         }
  69.         error = FSpOpenDF(&fileReply.sfFile, fsWrPerm, &dfRef);
  70.         CheckError(error, "\pFSpOpenDF");
  71.  
  72.         error = SetFPos(dfRef, fsFromStart, 0);
  73.         CheckError(error, "\pSetFPos");
  74.  
  75.         CompressSequence(&dfRef, &description);
  76.         error = GetFPos(dfRef, &filePos);
  77.         CheckError(error, "\pGetFPos");
  78.  
  79.         error = SetEOF(dfRef, filePos);
  80.         CheckError(error, "\pSetEOF");
  81.  
  82.         FlushVol(nil, fileReply.sfFile.vRefNum);
  83.         FSClose(dfRef);
  84.         dfRef = 0;
  85.         MakeMyResource(fileReply, description);
  86.         if (description != nil)
  87.             DisposeHandle((Handle)description);
  88.     }
  89. }
  90.  
  91.  
  92.